import { useMutation } from "@tanstack/react-query";
import { request } from "../api/request";
import { UPLOADAVATAR_URL } from "../constants/url";
const uploadFn = async (param) => {
  //

  const { data } = await request(
    {
      url: param.url ?? UPLOADAVATAR_URL,
      method: "put",
      data: param.data,
      headers: {
        "Content-Type": "multipart/form-data",
      },
    },
    true
  );
  return {
    data,
  };
};

export default function useUploadAvatar() {
  //
  return useMutation(["uploadAvatar"], uploadFn);
}
